<template>
	<view style="content">
		<view style="width: 750rpx;height: 100rpx;">
			<u-input v-model="value" :type="type" :border="border" :height="height" :auto-height="autoHeight"
				:custom-style="st" />
		</view>
		<view class="submit-box" @click="submit">
			提交信息
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				type: 'text',
				border: true,
				height: 100,
				autoHeight: true,
				st: {
					"font-size": "50rpx"
				},
				index: 0
			}
		},
		onLoad(option) {
			console.log(option.index)
			this.index = option.index;
		},
		methods: {
			submit() {
				var me = this;
				let token = uni.getStorageSync("usertoken");
				let data=uni.getStorageSync("accountInfo");
				if(me.index==0){
					data.ipname=me.value;
				}else if(me.index==1){
					data.name=me.value;
				}else if(me.index==2){
					data.gender=me.value;
				}else{
					data.address=me.value;
				}
				console.log(token)
				uni.request({
					url: me.serverUrl + "/user/editAccountInfo",
					data: {
						"ipName": data.ipname,
						"name": data.name,
						"gender": data.gender,
						"address": data.address
					},
					header: {
						"usertoken": token
					},
					method: "POST",
					success(res) {
						console.log(res.data)
						if (res.data.status == 200) {
							console.log(res.data)
							uni.setStorageSync("accountInfo",data);
							uni.navigateBack({
								delta:1
							})
							uni.showToast({
								title:"修改成功"
							})
						}
					},
					fail: () => {
						uni.showToast({
							duration: 800,
							title: "获取验证码失败"
						})
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;

		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 750rpx;
		height: 100%;
	}

	.submit-box {
		/* position: fixed;
		bottom: 40rpx; */
		margin: 100rpx auto;
		width: 700rpx;
		height: 100rpx;
		text-align: center;
		color: #FFFFFF;
		font-size: 50rpx;
		line-height: 100rpx;
		border-radius: 40rpx;
		background-color: #007AFF;
	}
</style>
